/**
 * 组件通讯的三种基本方式
 *
 * 兄弟组件之间的数据传递
 *
 */

 import React from "react";

 class Parent extends React.Component {
   state = {
     lastName: "王",
   };
 
   render() {
     return (
       <div>
         <div><h1>我是父组件，我姓：{this.state.lastName}</h1></div>
         <hr/>
         <ChildA lastName={this.state.lastName} />
         <hr/>
         <ChildB lastName={this.state.lastName} />
       </div>
     );
   }
 }
 
 class ChildA extends React.Component {
   render() {
     return (
       <div>
         <div>
           <h3>我是子组件A，我姓：{this.props.lastName}，子组件B的状态:{""}</h3>
         </div>
       </div>
     );
   }
 }
 
 class ChildB extends React.Component {
   render() {
     return (
       <div>
         <div><h3>我是子组件B，我姓：{this.props.lastName}</h3></div>
         <button onClick={this.onBeat}>我挨打了</button>
       </div>
     );
   }
 }
 
 export default Parent;
 